<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title> - equal.coffee</title>

  <link rel="stylesheet" href="../../../assets/style.css">
  
    
      <style>
        
      </style>
    
  

  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
  <meta name="groc-relative-root" content="../../../"/>
  <meta name="groc-document-path" content="../spec/shapes/equal.coffee"/>
  
</head>
<body>
  <div id="file-area">
    <div id="meta">
      <code class="file-path">
      
        <a href="https://github.com/legomushroom/mojs.git/blob/master/../spec/shapes/equal.coffee">../spec/shapes/equal.coffee</a>
      
      </code>
    </div>
    <div id="document">
    
      <div class="segment">
      
      
        <div class="code"><div class="wrapper">Equal  = mojs.Equal
Bit    = mojs.Bit
ns     = <span class="hljs-string">'http://www.w3.org/2000/svg'</span>
svg    = <span class="hljs-built_in">document</span>.createElementNS?(ns, <span class="hljs-string">"svg"</span>)

describe <span class="hljs-string">'Equal'</span>, <span class="hljs-function">-&gt;</span>
  it <span class="hljs-string">'should extend Bit'</span>, <span class="hljs-function">-&gt;</span>
    equal = <span class="hljs-keyword">new</span> Equal <span class="hljs-attribute">ctx</span>: svg
    expect(equal <span class="hljs-keyword">instanceof</span> Bit).toBe(<span class="hljs-literal">true</span>)
  it <span class="hljs-string">'have type of path'</span>, <span class="hljs-function">-&gt;</span>
    equal = <span class="hljs-keyword">new</span> Equal <span class="hljs-attribute">ctx</span>: svg
    expect(equal.type).toBe <span class="hljs-string">'path'</span>
  it <span class="hljs-string">'have ratio of 1.43'</span>, <span class="hljs-function">-&gt;</span>
    equal = <span class="hljs-keyword">new</span> Equal <span class="hljs-attribute">ctx</span>: svg
    expect(equal.ratio).toBe <span class="hljs-number">1.43</span>
  describe <span class="hljs-string">'methods -&gt;'</span>, <span class="hljs-function">-&gt;</span>
    describe <span class="hljs-string">'draw method -&gt;'</span>, <span class="hljs-function">-&gt;</span>
      it <span class="hljs-string">'should define points'</span>, <span class="hljs-function">-&gt;</span>
        equal = <span class="hljs-keyword">new</span> Equal
          <span class="hljs-attribute">ctx</span>:    <span class="hljs-built_in">document</span>.createElementNS?(ns, <span class="hljs-string">"svg"</span>)
          <span class="hljs-attribute">radius</span>: <span class="hljs-number">20</span>
        expect(equal.el.getAttribute(<span class="hljs-string">'d'</span>)).toBeTruthy()
      it <span class="hljs-string">'should not work with 0 points'</span>, <span class="hljs-function">-&gt;</span>
        equal = <span class="hljs-keyword">new</span> Equal
          <span class="hljs-attribute">ctx</span>:    <span class="hljs-built_in">document</span>.createElementNS?(ns, <span class="hljs-string">"svg"</span>)
          <span class="hljs-attribute">radius</span>: <span class="hljs-number">20</span>
          <span class="hljs-attribute">points</span>: <span class="hljs-number">0</span>
        expect(equal.el.getAttribute(<span class="hljs-string">'points'</span>)).toBeFalsy()

  describe <span class="hljs-string">'getLength method'</span>, <span class="hljs-function">-&gt;</span>
    it <span class="hljs-string">'should calculate total length of the path'</span>, <span class="hljs-function">-&gt;</span>
      radius = <span class="hljs-number">100</span>
      bit = <span class="hljs-keyword">new</span> Equal
        <span class="hljs-attribute">ctx</span>:    <span class="hljs-built_in">document</span>.createElementNS ns, <span class="hljs-string">'svg'</span>
        <span class="hljs-attribute">radius</span>: radius
      expect(bit.getLength()).toBe <span class="hljs-number">2</span>*radius

    it <span class="hljs-string">'should calculate total length of the with different radiusX/Y'</span>, <span class="hljs-function">-&gt;</span>
      radiusX = <span class="hljs-number">100</span>
      radiusY = <span class="hljs-number">50</span>
      bit = <span class="hljs-keyword">new</span> Equal
        <span class="hljs-attribute">ctx</span>:    <span class="hljs-built_in">document</span>.createElementNS ns, <span class="hljs-string">'svg'</span>
        <span class="hljs-attribute">radiusX</span>: radiusX
        <span class="hljs-attribute">radiusY</span>: radiusY
      expect(bit.getLength()).toBe <span class="hljs-number">2</span>*radiusX
</div></div>
      
      </div>
    
    </div>
  </div>

  <script src="../../../toc.js"></script>
  <script src="../../../assets/libs.js"></script>
  <script src="../../../assets/behavior.js"></script>

  
    
      <script>
        
      </script>
    
  
</body>
</html>